/*
自己选择的路 ,跪着也要走完。朋友们 , 虽然这个世界日益浮躁起来,只
要能够为了当时纯粹的梦想和感动坚持努力下去 , 不管其它人怎么样,我
们也能够保持自己的本色走下去。
To the world , you will be a person , but to a person , you
will be the world .                               ——AKPower
*/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
const ll maxn = 1100000;
ll prim1[maxn];
bool notprim2[maxn];
ll v[maxn];
//线性筛
ll f(ll n)
{
    ll m = 0;
    memset(v, 0, sizeof(v));
    for (ll i = 2; i <= n; i++)
    {
        if (v[i] == 0)
        {
            v[i] = i;
            prim1[m++] = i;
        }
        for (ll j = 0; j < m && prim1[j] <= v[i] && prim1[j] * i <= n; j++)
        {
            v[i * prim1[j]] = prim1[j];
        }
    }
    return m;
}

int main()
{
    IOS;
    ll l, r;
    // ll len=f(50000);
    while (cin >> l >> r)
    {
        ll len = f(sqrt((double)r)); //筛出[2,sqrt(r)]的所有素数
        l = max(l, (ll)2);
        memset(notprim2, false, sizeof(notprim2));
        for (ll i = 0; i < len; i++)
        {
            ll k = max((ll)ceil(l / (double)prim1[i]), (ll)2);
            while (k * prim1[i] <= r)
            {
                notprim2[k * prim1[i] - l] = true;      //k*prim1[i]-l将区间[l,r]左移为[0,r-l]
                k++;
            }
        }
        ll las, id = l;
        while (notprim2[id - l] && id <= r)             //找到第一个素数
        {
            id++;
        }
        las = id - l;
        id++;
        ll ans_min = 1000000, x1, y1;
        ll ans_max = 0, x2, y2;
        while (id <= r)
        {
            if (notprim2[id - l])               //非素数
            {
                id++;
                continue;
            }
            if (ans_min > id - l - las)         //找最近的素数
            {
                x1 = las;
                y1 = id - l;
                ans_min = id - l - las;
            }
            if (ans_max < id - l - las)        //找最远的素数
            {
                ans_max = id - l - las;
                x2 = las;
                y2 = id - l;
            }
            las = id - l;
            id++;
        }
        if (ans_max > 0)
        {
            printf("%lld,%lld are closest, %lld,%lld are most distant.\n", x1 + l, y1 + l, x2 + l, y2 + l);
        }
        else
        {
            printf("There are no adjacent primes.\n");
        }
    }
    getchar();
    getchar();
    return 0;
}
